package com.sec.android.app.myfiles.module.local.category;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sec.android.app.myfiles.R;
import com.sec.android.app.myfiles.fragment.home.HomeFragment;
import com.sec.android.app.myfiles.info.AppConstants;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.util.UiUtils;

/**
 * Created by daelight.kim on 2017-2-7.
 */
public class PickerCategoryHomeItem extends CategoryHomeItem {
    PickerCategoryHomeItem(Context context, HomeFragment fragment) {
        super(context, fragment);
    }

    @Override
    protected void setListItem() {

        HomeItemInfo item;
        HomeItemClickListener onclick;
        FileRecord record;

        View categoryView = mRootView.findViewById(R.id.home_picker_category);
        setViewVisibility(categoryView, View.VISIBLE);
        View categoryHeader = mRootView.findViewById(R.id.home_picker_category_header);
        setViewVisibility(categoryHeader, View.VISIBLE);

        record = FileRecord.createFileRecord(FileRecord.StorageType.Category, AppConstants.StoragePath.CATEGORY_IMAGE);
        onclick = new HomeItemClickListener(record, "Category-Images");
        item = new HomeItemInfo(R.id.home_picker_item_image_stub, R.id.home_picker_item_image, R.drawable.my_files_ic_image,
                R.color.home_icon_image_color, R.color.home_icon_image_bg_color, R.string.images, onclick);
        mItemList.add(item);

        record = FileRecord.createFileRecord(FileRecord.StorageType.Category, AppConstants.StoragePath.CATEGORY_VIDEO);
        onclick = new HomeItemClickListener(record, "Category-Videos");
        item = new HomeItemInfo(R.id.home_picker_item_video_stub, R.id.home_picker_item_video, R.drawable.my_files_ic_video,
                R.color.home_icon_video_color, R.color.home_icon_video_bg_color, R.string.videos, onclick);
        mItemList.add(item);

        record = FileRecord.createFileRecord(FileRecord.StorageType.Category, AppConstants.StoragePath.CATEGORY_AUDIO);
        onclick = new HomeItemClickListener(record, "Category-Audio");
        item = new HomeItemInfo(R.id.home_picker_item_music_stub, R.id.home_picker_item_music, R.drawable.my_files_ic_music,
                R.color.home_icon_music_color, R.color.home_icon_music_bg_color, R.string.audio, onclick);
        mItemList.add(item);

        record = FileRecord.createFileRecord(FileRecord.StorageType.Category, AppConstants.StoragePath.CATEGORY_DOCUMENT);
        onclick = new HomeItemClickListener(record, "Category-Documents");
        item = new HomeItemInfo(R.id.home_picker_item_document_stub, R.id.home_picker_item_document, R.drawable.my_files_ic_document,
                R.color.home_icon_document_color, R.color.home_icon_document_bg_color, R.string.documents, onclick);
        mItemList.add(item);

        record = FileRecord.createFileRecord(FileRecord.StorageType.Category, AppConstants.StoragePath.CATEGORY_APK);
        onclick = new HomeItemClickListener(record, "APK Collector");
        item = new HomeItemInfo(R.id.home_picker_item_apk_stub, R.id.home_picker_item_apk, R.drawable.myfiles_ic_apk, R.color.home_icon_apk_color, R.color.home_icon_apk_bg_color, UiUtils.getInstallationFileString(), onclick);
        mItemList.add(item);

        for (HomeItemInfo homeItem : mItemList) {
            if (homeItem.itemView != null) {
                TextView sizeView = (TextView) homeItem.itemView.findViewById(R.id.home_list_item_text_second);
                setViewVisibility(sizeView, View.GONE);
            }
        }
    }

    @Override
    public void updateCategoryItemLayout() {
        /**
         * Do nothing
         */
    }
}
